<div class="SipeiInfo border_3 pt20 pb20 centered back_bgf"><!--选修课等级分数设置-弹窗-新增-->
    <form method='post' action='<?php echo $this->createUrl('/question_collect/default/update') ?>'  id="searchForm" target="ajax-frame">
        <table width="473" class="fontc_666 height32">
            <tbody>
            <input type="hidden" name="info[id]" value="<?php echo $date['data']['id']?>">
                <tr height="55">
                    <td align="right" valign="top" width="120" class="pr5"><span class="pr5 fontc_orange_red">*</span>考试项目：</td>
                    <td valign="top" width="348" class="formValidator_td">
                    	<span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                    	<span class="fl select_shelter">
                            <select name="info[exam_id]" id="exam_id" class="fl fontc_666" onchange="checksubject(this.value)">
                                <option value="">请选择</option>
                                <?php if ($date['examall']): foreach ($date['examall'] as $one): ?>
                                    <option value="<?php echo $one['exam_id']; ?>" <?php if($date['data']['exam_id']==$one['exam_id']):?>selected<?php endif;?>><?php echo $one['exam_term_name'];?></option>
                                <?php endforeach; endif;?>
                            </select>
                        </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="exam_idTip" ></p>
                        </div>
                	</td>
                </tr>
                <tr height="55">
                    <td align="right" valign="top" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属科目：</td>
                    <td valign="top" class="formValidator_td">
                    	<span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select name="info[subject_id]" id="subject_id" class="fl fontc_666" onchange="getallfields(this.value)">
                            	<option value="">请选择</option>
                            	<?php if ($date['subjectall']): foreach ($date['subjectall'] as $one): ?>
                           		<option value="<?php echo $one['subject_id']; ?>" <?php if($date['data']['subject_id']==$one['subject_id']):?>selected<?php endif;?>><?php echo $one['subject_name']; ?></option>
                            	<?php endforeach;endif;?>
							</select>
                        </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="subject_idTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td align="right" valign="top" class="pr5"><span class="pr5 fontc_orange_red">*</span>汇总栏位：</td>
                    <td valign="top" class="formValidator_td">
                    	<span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select name="info[collect_fields]" id="collect_fields" class="fl fontc_666">
                             	<option value="">请选择</option>
                             	<?php if ($date['row_config']): foreach ($date['row_config'] as $k=>$one): ?>
                           		<option value="<?php echo $k; ?>" <?php if($date['data']['collect_fields']==$k):?>selected<?php endif;?>><?php echo $one; ?></option>
                            	<?php endforeach;endif;?>
							</select>
                        </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_fieldsTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>汇总方式：</td>
                    <td valign="top" class="formValidator_td">
                    	<span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[collect_mode]" id="collect_mode" class="fl fontc_666" onchange="getmode(this.value)">
                                    <option value="">请选择</option>
                                    <?php if ($date['collect_mode']): foreach ($date['collect_mode'] as $k=>$v): ?>
                                            <option value="<?php echo $k; ?>" <?php if($date['data']['collect_mode']==$k):?>selected<?php endif;?>><?php echo $v; ?></option>
                                    <?php endforeach;endif;?>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_modeTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55" id="mode1" class="mode" <?php if ($date['data']['collect_mode']==2):?> style="display:none" <?php endif;?>>
                    <td valign="top" align="right" class="pr5">题型选择：</td>
                    <td valign="top">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[collect_questions]" id="collect_questions" class="fl fontc_666">
                                    <option value="">请选择</option>
                                    <?php if ($one['collect_fields']):?>
                                    <?php $subjecttype = SmallProblem::_getquestions($date['data']['subject_id']);?>
                                    <?php foreach ($subjecttype as $k=>$v):?>
                                    <option value="<?php echo $k;?>" <?php if($date['data']['collect_questions']==$k):?>selected<?php endif;?>><?php echo $v;?></option>
                                    <?php endforeach;?>
                                      <?php endif;?>
                                </select>
                            </span>
                        </span>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>题号包含'_'不统计：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3  border_3">
                            <span class="fl select_shelter">
                                <input type="checkbox" name="info[no_statis_unline]" value="1" <?php if($date['data']['no_statis_unline']==1):?>checked="checked"<?php endif;?>>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_modeTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>保留小数位：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[dot_num]"  class="fl fontc_666">
                                    <option value="0" <?php if($date['data']['dot_num']!=1):?>selected<?php endif;?>>0</option>
                                    <option value="1" <?php if($date['data']['dot_num']==1):?>selected<?php endif;?>>1</option>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_modeTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr id="mode2" class="mode" <?php if ($date['data']['collect_mode']==1):?> style="display:none" <?php endif;?>>
                    <td valign="top" align="right" class="pt15 pr5">题号选择：</td>
                    <td valign="top" class="pt15">
                        <div class="select_t_select" style="clear:both;">
                            <div class="dep_ben_list fl">
                                <div class="ben_title"></div>
                                <select style="width:130px;height:150px;" id="user_select" size="3" multiple="">
                                <?php if (!empty($date['data']['exam_id']) && !empty($date['data']['subject_id']) && $date['data']['collect_mode']==2):?>
                                <?php $where = 'AND "exam_id" = '.$date['data']['exam_id'].' AND "subject_id" = '.$date['data']['subject_id'];
                                $subjectquestion = SmallProblem::_getquestion_num($where);
                                foreach ($subjectquestion as $n):
                                ?>
								<?php if (!strstr($date['data']['collect_question'],$n['id'])):?>
                                <option value="<?php echo $n['id'];?>" ><?php echo $n['num_id'];?></option>
								<?php endif;?>
                                    <?php endforeach;?>
                                <?php endif;?>
                                </select>
                            </div>
                            <div class="dep_ben_btn fl"> 
                                <a style="display:block; margin:10px 5px; margin-top:40px;" class="right" href="javascript:;"><img src="/themes/default/images/Sipei/btn_ben_right.gif"></a> 
                                <a "="" style="display:block; margin:10px 5px;" class="left" href="javascript:;"><img src="/themes/default/images/Sipei/btn_ben_left.gif"></a> 
                            </div>
                            <div class="dep_ben_list fl">
                                <div class="ben_title"></div>
                                <select style="width:130px;height:150px;" name="info[collect_question][]" id="userNameSelected" size="3" multiple="">
                                <?php if (!empty($date['data']['exam_id']) && !empty($date['data']['subject_id']) && $date['data']['collect_mode']==2):?>
                                <?php 
                                $wheres = ' AND "id" IN('.$date['data']['collect_question'].')';
                                $subjectquestions = SmallProblem::_getquestion_num($wheres);
                                foreach ($subjectquestions as $n):
                                ?>
                                <option value="<?php echo $n['id'];?>" selected><?php echo $n['num_id'];?></option>
                                    <?php endforeach;?>
                                <?php endif;?>
                                </select>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="pt20 pr5 pb20"></td>
                    <td class="pt20 pb20">
                        <input type="submit" value="保存" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10 cursor" name="submit" />
                        <input type="button" onclick="api.close();" value="取消" class="b_a_n border_3 back_bgb w80 height32 fontc_FFF fonts_12 cursor" />
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script>
$(function() {
	$(".select_t").bind("click", function() {
		$(".select_t_select").show();
	});
	var oUser = $('#user_select');
	$('.right').click(function() {
		var s = oUser.find('option:selected');
		$('#userNameSelected').find("option").attr("selected", false)
		s.appendTo($('#userNameSelected'));
		return false;
	});
	$('.left').click(function() {
		var s = $('#userNameSelected').find('option:selected');
		s.appendTo(oUser);
		return false;
	});
})
//项目科目联动
function checksubject(val){
	$.post('/question_collect/default/ajaxvalue', {id: val}, function(result) {
		var dataObj=eval("("+result+")");//转换为json对象
		var subjectstr = '';
		$.each(dataObj,function(i,item){
			subjectstr += "<option value='" + item.subject_id + "'>" + item.subject_name + "</option>"
		});
		$("#subject_id").html(subjectstr);
	});
}
//获取栏位
function getallfields(subject_id){
	var collect_mode =$("#collect_mode").val();
	if(collect_mode !=''){
		getmode(collect_mode);
	}
}
function getmode(val){
	var msg="";
	var exam_id =$("#exam_id").val();
	var subject_id =$("#subject_id").val();
	if(exam_id=='' || subject_id==''){
		msg="请选择项目和科目";
	}else{
		if(val==1){
			$.post('/question_collect/default/sujectquestions',{subject_id:subject_id},function(result){
				var obj = $.parseJSON(result), newHtml = "";
				$.each(obj, function(i, item) {
					newHtml += "<option value='" + i + "'>" + item + "</option>"
				})
				$("#collect_questions").html(newHtml);
			});
		}
		if(val==2){
			$.post('/question_collect/default/sujectquestion',{exam_id:exam_id,subject_id:subject_id},function(result){
				var obj = $.parseJSON(result), newHtml = "";
				$.each(obj, function(i, item) {
					newHtml += "<option value='" +item['id'] + "'>" + item['num_id'] + "</option>"
				})
				$("#user_select").html(newHtml);
			});
		}
		$(".mode").hide();
		$("#mode"+val).show();
		msg = true;
	}
	return msg;
}

$("#searchForm").submit(function(){
	 $("#userNameSelected option").attr("selected", true);
})

$(function(){
	$.formValidator.initConfig({formID:"searchForm",theme:"126",submitOnce:false,
	onError:function(msg,obj,errorlist){
		$("#errorlist").empty();
		$.map(errorlist,function(msg){
			$("#errorlist").append("<li>" + msg + "</li>")
		});
		alert(msg);
	},
	ajaxPrompt : '有数据正在异步验证，请稍等...'
	});
	/*考试项目验证*/
	$("#exam_id").formValidator({
		onShowText:"请输入考试项目",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"考试项目不能为空"
	});
	/*汇总栏位验证*/
	$("#collect_fields").formValidator({
		onShowText:"请输入汇总栏位",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"汇总栏位不能为空"
	});
	/*汇总方式验证*/
	$("#collect_mode").formValidator({
		onShowText:"请输入汇总方式",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"汇总方式不能为空"
	}).functionValidator({fun:getmode});

})
</script>
<?php exit; ?>